<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="采砂场统计分析">

    <!--suppress ALL -->
<div class="xm-offline">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a class="back" href="/rest/manage/weightrecord/toSandPitCount">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="searchForm" class="form-panel" action="/rest/manage/dataAnalyse/selectSandpitDetailPage" method="get">
                    <ul class="panel-content">
                        <div  style="height: auto;overflow: hidden;line-height: 30px">
                            <div class="clearfix item">
                                <select name="cartNo" class="car select-box pull-left">
                                    <option value="">请选择车辆</option>
                                    <option value="豫1234">豫1234</option>
                                    <option value="豫255">豫255</option>
                                </select>
                                <select name="productName" class="product select-box pull-left mar10">
                                    <option value="">请选择品名</option>
                                    <option value="铝凡土">铝凡土</option>
                                    <option value="河沙">河沙</option>
                                    <option value="ewt">ewt</option>
                                </select>
                                <div class="form-actions  controls pull-left ">
                                    <button type="submit" class="button button-success search-box">
                                        查询
                                    </button>
                                </div>
                            </div>
                            <div class="control-group controls span6">
                                <label class=" label-text">
                                    统计总重量：
                                </label>
                                <div class="span3">
                                    <input type="text" class="input-normal  input-pad cartNo label-input"
                                           id="weight" readonly>
                                </div>
                            </div>
                            <div class="control-group controls span6">
                                <label class=" label-text">
                                    统计总次数：
                                </label>
                                <div class="span3">
                                    <input type="text" class="input-normal  input-pad cartNo label-input"
                                           id="count" readonly>
                                </div>
                            </div>
                            <div class="control-group controls span6">
                                <label class=" label-text">
                                    统计总价格：
                                </label>
                                <div class="span3">
                                    <input type="text" class="input-normal  input-pad cartNo label-input"
                                           id="price" readonly>
                                </div>
                            </div>

                        </div>
                    </ul>
                </form>
                <div id="grid"></div>
            </div>
        </div>
    </div>
</div>

<script>
    var type = getQueryString('type');
    var endDate=getQueryString('endDate');
    var startDate=getQueryString('startDate');
    var sandpit=getQueryString('sandpit');
    sandpit=sandpit==1?'涂庄':'马庄';
    var url;
    var normalData={
        length: '10',
        endDate:endDate,
        startDate:startDate,
        sandpit:sandpit,
        start:0,
        limit:10,
        pageIndex:0
    };
    var Grid = BUI.Grid,
            Calendar = BUI.Calendar,
            datePicker = new Calendar.DatePicker({
                trigger: '.calendar',
                dateMask: 'yyyy/mm/dd',
                autoRender: true
            }),
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', elCls: 'center', dataIndex: 'id', width: '11%',renderer:function (value,obj,index){
                        return index+1;
                    }},
                {title: '车牌号', elCls: 'center', dataIndex: 'cartNo', width: '11%'},
                {title : '司机',elCls: 'center', dataIndex :'driver', width:'11%',renderer:function (value){
                        return value||'-';
                    } },
                {title: '品名', elCls: 'center', dataIndex: 'productName', width: '11%'},
                {title : '毛重(KG)',elCls: 'center', dataIndex :'totalWeight', width:'11%'},
                {title : '皮重(KG)',elCls: 'center', dataIndex :'cartWeight', width:'11%'},
                {title : '净重(KG)',elCls: 'center', dataIndex :'sandWeight', width:'11%'},
                {title : '金额(元)',elCls: 'center', dataIndex :'money', width:'11%'},
                {title: '日期记录', elCls: 'center', dataIndex: 'createTime', width: '11%'},
            ];

    var store = new Store({
                url: '/rest/manage/dataAnalyse/selectSandpitDetailPage',
                autoLoad: true, //自动加载数据
                params: normalData,
                pageSize: 10,	// 配置分页数目
                root: 'list',
                totalProperty: 'total'
            }),
            grid = new Grid.Grid({
                render: '#grid',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                // 底部工具栏
                bbar: {pagingBar: true}
            });
    grid.render();
    function queryTotal(obj) {
        $.ajax({
            type:'GET',
            data:obj,
            url:'/rest/manage/dataAnalyse/selectSandpitDetailPage',
            dataType:'json',
            success:function (data) {
                var res=data.list[0];
                $('#weight').val(res.sandWeightAmount);
                $('#count').val(res.recordAmount);
                $('#price').val(res.moneyAmount);
            }
        })
    }
    queryTotal(normalData)
    //查询框
    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    $('.search-box').click(function () {
        var obj={
            sandpit:$('.sand ').val(),
            cartNo:$('.car').val(),
            productName:$('.product').val()
        }
        obj=$.extend(obj,normalData)
        queryTotal(obj)
    })
</script>

</@page.pageBase>
